/**
 * @file   Property.cpp
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2013-05-16
 * @brief  DataBus Property.
 *
 * Copyright (C) 2013 Djuro Drljaca <djurodrljaca@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <DataBus/Common/Property.h>

DataBus::Property::Property()
    : m_propertyInfo(),
      m_value()
{
}

DataBus::Property::Property(const PropertyInfo &propertyInfo,
                            const Value &defaultValue)
    : m_propertyInfo(propertyInfo),
      m_value(defaultValue)
{
}

DataBus::PropertyInfo DataBus::Property::getPropertyInfo() const
{
    return m_propertyInfo;
}

bool DataBus::Property::setPropertyInfo(const PropertyInfo &propertyInfo)
{
    // Check Property Info
    if (propertyInfo.isValid() == false)
    {
        // Error, invalid Property Info
        return false;
    }

    // Save Property Info
    m_propertyInfo = propertyInfo;

    // Success
    return true;
}

DataBus::Value DataBus::Property::getValue() const
{
    return m_value;
}

bool DataBus::Property::setValue(const Value &value)
{
    // Check Value
    if (value.isValid() == false)
    {
        // Error, invalid Value
        return false;
    }

    // Save Value
    m_value = value;

    // Success
    return true;
}
